package com.bingo.mpa.portal;

import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;

import org.express.portal.ActionContext;
import org.express.portal.HttpUtils;
import org.express.portal.Mapping;
import org.express.portal.Utils;
import org.express.portal.persist.QueryHelper;
import org.express.portal.renderer.RedirectRenderer;
import org.express.portal.renderer.Renderer;
import org.express.portal.renderer.TemplateRenderer;
import org.express.portal.renderer.TextRenderer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.bingo.mpa.pojo.Log;
import com.bingo.mpa.service.LogService;
import com.bingo.mpa.util.RandomValidateCode;
import com.bingo.mpa.vo.DateMeta;
import com.bingo.mpa.vo.Stat;

public class Portal
{
	private final Logger log = LoggerFactory.getLogger(getClass());
	
	@Mapping("/")
	public Renderer home()
	{
		try
		{
			String token = HttpUtils.getCookie("mpa_token");
			String sql = "SELECT * FROM P_USER WHERE TOKEN=?";
			if(token == null)
			{
				return new RedirectRenderer("/login");
			}
			com.bingo.mpa.pojo.User user = QueryHelper.read_cache(com.bingo.mpa.pojo.User.class, "user", token, sql, new Object[]{token});
			if(user == null)
			{
				return new RedirectRenderer("/login");
			}
			byte role = user.getRole();
			switch(role)
			{
				case 1:
					return new RedirectRenderer("/admin");
				case 2:
					return new RedirectRenderer("/operate");
				case 3:
					return new RedirectRenderer("/sale");
				case 4:
					return new RedirectRenderer("/manager");
			}
		}
		catch(Exception e)
		{
			log.error("",e);
		}
		return new RedirectRenderer("/login");
	}
	
	@Mapping("/login")
	public Renderer login()
	{
		return new TemplateRenderer("/login.html");
	}

	@Mapping("/verify/code/generate")
	public void verfiy_code_generate()
	{
		RandomValidateCode.getInstance().getRandcode(ActionContext.getActionContext().getHttpServletRequest(), ActionContext.getActionContext().getHttpServletResponse());
	}
	
	@Mapping("/logon")
	public Renderer logon()
	{
		Map<String,Object> model = new HashMap<String,Object>();
		String account = HttpUtils.getStringParameter("account");
		String verifycode = HttpUtils.getStringParameter("verifycode");
		String validate_code = (String)ActionContext.getActionContext().getHttpServletRequest().getSession().getAttribute("RANDOMVALIDATECODEKEY");
		if(verifycode != null && validate_code !=null){
			if(!validate_code.toLowerCase().equals(verifycode.toLowerCase()))
			{
				model.put("error", "验证码输入错误");
				return new TemplateRenderer("/login.html","model",model);
			}
		}
		String sql = "SELECT * FROM P_USER WHERE ACCOUNT=?";
		com.bingo.mpa.pojo.User user = QueryHelper.get(com.bingo.mpa.pojo.User.class, sql, new Object[]{account});
		if(user == null)
		{
			model.put("error", "帐号不存在或密码错误");
			return new TemplateRenderer("/login.html","model",model);
		}
		else
		{
			String password = HttpUtils.getStringParameter("password");
			if(!user.getPwd().equals(Utils.getMd5Sum(password)))
			{
				Calendar now = Calendar.getInstance();
				now.add(Calendar.MINUTE, -5);//锁定时间
				Date lastLogin = user.getLast_login_time();
				if(lastLogin == null || lastLogin.before(now.getTime()))
				{
					model.put("error", "帐号不存在或密码错误");
					String clientIp = ActionContext.getActionContext().getHttpServletRequest().getRemoteAddr();
					String _update = "UPDATE P_USER SET THIS_LOGIN_TIME=?,THIS_LOGIN_IP=?,LAST_LOGIN_TIME=?,LAST_LOGIN_IP=?,ERROR_COUNT=? WHERE UID=?";
					QueryHelper.update(_update, new Object[]{new java.sql.Timestamp(Calendar.getInstance(Locale.CHINA).getTimeInMillis()),clientIp,user.getThis_login_time(),user.getThis_login_ip(),user.getError_count()+1,user.getUid()});
					
					Log log = new Log(clientIp,(byte)1,(byte)3,"工号为"+user.getAccount()+"的用户登录系统失败，密码错误！");
					LogService.getInstance().write(log);
					return new TemplateRenderer("/login.html","model",model);
				}
				else
				{
					if(user.getError_count() >=5)
					{
						model.put("error", "连续三次输错密码，帐号已被锁定！");
						String clientIp = ActionContext.getActionContext().getHttpServletRequest().getRemoteAddr();
						String _update = "UPDATE P_USER SET STATUS=?,THIS_LOGIN_TIME=?,THIS_LOGIN_IP=?,LAST_LOGIN_TIME=?,LAST_LOGIN_IP=?,ERROR_COUNT=? WHERE UID=?";
						QueryHelper.update(_update, new Object[]{3,new java.sql.Timestamp(Calendar.getInstance(Locale.CHINA).getTimeInMillis()),clientIp,user.getThis_login_time(),user.getThis_login_ip(),user.getError_count()+1,user.getUid()});
						
						Log log = new Log(clientIp,(byte)1,(byte)3,"工号为"+user.getAccount()+"的用户连续三次输错密码，帐号被锁定！");
						LogService.getInstance().write(log);
						return new TemplateRenderer("/login.html","model",model);
					}
					else if(user.getError_count() >=2)
					{
						model.put("error", "您已输错两次密码，三次输错密码帐号将被锁定！");
						String clientIp = ActionContext.getActionContext().getHttpServletRequest().getRemoteAddr();
						String _update = "UPDATE P_USER SET THIS_LOGIN_TIME=?,THIS_LOGIN_IP=?,LAST_LOGIN_TIME=?,LAST_LOGIN_IP=?,ERROR_COUNT=? WHERE UID=?";
						QueryHelper.update(_update, new Object[]{new java.sql.Timestamp(Calendar.getInstance(Locale.CHINA).getTimeInMillis()),clientIp,user.getThis_login_time(),user.getThis_login_ip(),user.getError_count()+1,user.getUid()});
						
						Log log = new Log(clientIp,(byte)1,(byte)3,"工号为"+user.getAccount()+"的用户登录系统失败，密码错误！");
						LogService.getInstance().write(log);
						return new TemplateRenderer("/login.html","model",model);
					}
				}
			}
			else
			{
				byte status = user.getStatus();
				byte role = user.getRole();
				switch(status)
				{
					case 1:
						model.put("error", "您的帐号尚未激活，请联系管理员！");
						break;
					case 2:
						String token = Utils.generateToken();
						user.setToken(token);
						user.setOnline(1);
						HttpUtils.setCookie("mpa_token", token, 5400,"/");
						String clientIp = ActionContext.getActionContext().getHttpServletRequest().getRemoteAddr();
						String _update = "UPDATE P_USER SET ONLINE=?,TOKEN=?,THIS_LOGIN_TIME=?,THIS_LOGIN_IP=?,LAST_LOGIN_TIME=?,LAST_LOGIN_IP=?,ERROR_COUNT=? WHERE UID=?";
						QueryHelper.update(_update, new Object[]{1,token,Calendar.getInstance(Locale.CHINA).getTime(),clientIp,user.getThis_login_time(),user.getThis_login_ip(),0,user.getUid()});
						
						Log log = new Log(clientIp,(byte)1,(byte)1,"工号为"+user.getAccount()+"的用户登录系统，成功！");
						LogService.getInstance().write(log);
						switch(role)
						{
							case 1:
								return new RedirectRenderer("/admin");
							case 2:
								return new RedirectRenderer("/operate");
							case 3:
								return new RedirectRenderer("/sale");
							case 4:
								return new RedirectRenderer("/manager");
						}
					case 3:
						Calendar now = Calendar.getInstance();
						now.add(Calendar.MINUTE, -3);
						
						Date lastLogin = user.getLast_login_time();
						if(lastLogin != null && lastLogin.after(now.getTime()))
						{
							if(user.getError_count() >= 5)
							{
								model.put("error", "您的帐号已被锁定，请联系管理员！");
							}
						}
						else
						{
							token = Utils.generateToken();
							user.setToken(token);
							user.setOnline(1);
							HttpUtils.setCookie("mpa_token", token, 5400,"/");
							clientIp = ActionContext.getActionContext().getHttpServletRequest().getRemoteAddr();
							_update = "UPDATE P_USER SET STATUS=?,ONLINE=?,TOKEN=?,THIS_LOGIN_TIME=?,THIS_LOGIN_IP=?,LAST_LOGIN_TIME=?,LAST_LOGIN_IP=?,ERROR_COUNT=? WHERE UID=?";
							QueryHelper.update(_update, new Object[]{2,1,token,Calendar.getInstance(Locale.CHINA).getTime(),clientIp,user.getThis_login_time(),user.getThis_login_ip(),0,user.getUid()});
							
							log = new Log(clientIp,(byte)1,(byte)1,"工号为"+user.getAccount()+"的用户登录系统，成功！");
							LogService.getInstance().write(log);
							switch(role)
							{
								case 1:
									return new RedirectRenderer("/admin");
								case 2:
									return new RedirectRenderer("/operate");
								case 3:
									return new RedirectRenderer("/sale");
								case 4:
									return new RedirectRenderer("/manager");
							}
						}
						break;
					case 4:
						model.put("error", "您的帐号已被注销，请联系管理员！");
						break;
					case 5:
						model.put("error", "您的帐号未通过审核，请联系管理员！");
						break;
				}
			}
		}
		return new TemplateRenderer("/login.html","model",model);
	}
	
	@Mapping("/admin")
	public Renderer admin()
	{
		Map<String,Object> model = new HashMap<String,Object>();
		try
		{
			String token = HttpUtils.getCookie("mpa_token");
			String sql = "SELECT * FROM P_USER WHERE TOKEN=?";
			if(token == null)
			{
				return new RedirectRenderer("/login");
			}
			com.bingo.mpa.pojo.User user = QueryHelper.read_cache(com.bingo.mpa.pojo.User.class, "user", token, sql, new Object[]{token});
			if(user == null)
			{
				return new RedirectRenderer("/login");
			}
			model.put("user", user);
			byte role = user.getRole();
			switch(role)
			{
				case 2:
				case 3:
				case 4:
					return new RedirectRenderer("/login");
				case 1:
					//sql = "SELECT * FROM P_ORDER ORDER BY ORDER_TIME DESC LIMIT 9";
					sql = "SELECT s.NAME,o.* FROM P_STORE s,P_ORDER o WHERE s.SID=o.SID ORDER BY ORDER_TIME DESC LIMIT 9";
					List<com.bingo.mpa.vo.OrderVO> list = QueryHelper.query(com.bingo.mpa.vo.OrderVO.class, sql, new Object[]{});
					
					sql = "SELECT * FROM P_PACKAGE";
					List<com.bingo.mpa.pojo.Package> lp = QueryHelper.query_cache(com.bingo.mpa.pojo.Package.class, "packages", "packages", sql, new Object[]{});
					Map<Integer,com.bingo.mpa.pojo.Package> map = new HashMap<Integer,com.bingo.mpa.pojo.Package>();
					if(lp != null && lp.size() > 0)
					{
						for(com.bingo.mpa.pojo.Package obj : lp)
						{
							map.put(obj.getPid(), obj);
						}
					}
					model.put("list", list);
					model.put("packages", map);
					return new TemplateRenderer("/admin.html","model",model);
			}
		}
		catch(Exception e)
		{
			log.error("",e);
		}
		return new TemplateRenderer("/admin.html","model",model);
	}
	
	@Mapping("/operate")
	public Renderer operate()
	{
		Map<String,Object> model = new HashMap<String,Object>();
		try
		{
			String token = HttpUtils.getCookie("mpa_token");
			String sql = "SELECT * FROM P_USER WHERE TOKEN=?";
			if(token == null)
			{
				return new RedirectRenderer("/login");
			}
			com.bingo.mpa.pojo.User user = QueryHelper.read_cache(com.bingo.mpa.pojo.User.class, "user", token, sql, new Object[]{token});
			if(user == null)
			{
				return new RedirectRenderer("/login");
			}
			model.put("user", user);
			byte role = user.getRole();
			switch(role)
			{
				case 1:
				case 3:
				case 4:
					return new RedirectRenderer("/login");
				case 2:
					//sql = "SELECT * FROM P_ORDER ORDER BY ORDER_TIME DESC LIMIT 9";
					sql = "SELECT s.NAME,o.* FROM P_STORE s,P_ORDER o WHERE s.SID=o.SID ORDER BY ORDER_TIME DESC LIMIT 9";
					List<com.bingo.mpa.vo.OrderVO> list = QueryHelper.query(com.bingo.mpa.vo.OrderVO.class, sql, new Object[]{});
					
					sql = "SELECT * FROM P_PACKAGE";
					List<com.bingo.mpa.pojo.Package> lp = QueryHelper.query_cache(com.bingo.mpa.pojo.Package.class, "packages", "packages", sql, new Object[]{});
					Map<Integer,com.bingo.mpa.pojo.Package> map = new HashMap<Integer,com.bingo.mpa.pojo.Package>();
					if(lp != null && lp.size() > 0)
					{
						for(com.bingo.mpa.pojo.Package obj : lp)
						{
							map.put(obj.getPid(), obj);
						}
					}
					model.put("list", list);
					model.put("packages", map);
					return new TemplateRenderer("/operate.html","model",model);
			}
		}
		catch(Exception e)
		{
			log.error("",e);
		}
		return new TemplateRenderer("/operate.html","model",model);
	}
	
	@Mapping("/sale")
	public Renderer sale()
	{
		Map<String,Object> model = new HashMap<String,Object>();
		try
		{
			String token = HttpUtils.getCookie("mpa_token");
			String sql = "SELECT * FROM P_USER WHERE TOKEN=?";
			if(token == null)
			{
				return new RedirectRenderer("/login");
			}
			com.bingo.mpa.pojo.User user = QueryHelper.read_cache(com.bingo.mpa.pojo.User.class, "user", token, sql, new Object[]{token});
			if(user == null)
			{
				return new RedirectRenderer("/login");
			}
			model.put("user", user);
			byte role = user.getRole();
			switch(role)
			{
				case 1:
				case 2:
				case 4:
					return new RedirectRenderer("/login");
				case 3:
					sql = "SELECT * FROM P_ORDER WHERE S_ACCOUNT=? ORDER BY ORDER_TIME DESC LIMIT 9";
					List<com.bingo.mpa.pojo.Order> list = QueryHelper.query(com.bingo.mpa.pojo.Order.class, sql, new Object[]{user.getAccount()});
					
					sql = "SELECT * FROM P_PACKAGE";
					List<com.bingo.mpa.pojo.Package> lp = QueryHelper.query_cache(com.bingo.mpa.pojo.Package.class, "packages", "packages", sql, new Object[]{});
					Map<Integer,com.bingo.mpa.pojo.Package> map = new HashMap<Integer,com.bingo.mpa.pojo.Package>();
					if(lp != null && lp.size() > 0)
					{
						for(com.bingo.mpa.pojo.Package obj : lp)
						{
							map.put(obj.getPid(), obj);
						}
					}
					model.put("list", list);
					model.put("packages", map);
					return new TemplateRenderer("/sale.html","model",model);
			}
		}
		catch(Exception e)
		{
			log.error("",e);
		}
		return new TemplateRenderer("/sale.html","model",model);
	}
	
	/**
	 * 代理商管理员
	 * @return
	 */
	@Mapping("/manager")
	public Renderer manager()
	{
		Map<String,Object> model = new HashMap<String,Object>();
		try
		{
			String token = HttpUtils.getCookie("mpa_token");
			String sql = "SELECT * FROM P_USER WHERE TOKEN=?";
			if(token == null)
			{
				return new RedirectRenderer("/login");
			}
			com.bingo.mpa.pojo.User user = QueryHelper.read_cache(com.bingo.mpa.pojo.User.class, "user", token, sql, new Object[]{token});
			if(user == null)
			{
				return new RedirectRenderer("/login");
			}
			model.put("user", user);
			byte role = user.getRole();
			switch(role)
			{
				case 1:
				case 2:
				case 3:
					return new RedirectRenderer("/login");
				case 4:
					//sql = "SELECT * FROM P_ORDER ORDER BY ORDER_TIME DESC LIMIT 9";
					sql = "SELECT s.NAME,o.* FROM P_STORE s,P_ORDER o WHERE s.SID=o.SID AND o.AID = ? ORDER BY ORDER_TIME DESC LIMIT 9";
					List<com.bingo.mpa.vo.OrderVO> list = QueryHelper.query(com.bingo.mpa.vo.OrderVO.class, sql, new Object[]{user.getAid()});
					
					sql = "SELECT * FROM P_PACKAGE";
					List<com.bingo.mpa.pojo.Package> lp = QueryHelper.query_cache(com.bingo.mpa.pojo.Package.class, "packages", "packages", sql, new Object[]{});
					Map<Integer,com.bingo.mpa.pojo.Package> map = new HashMap<Integer,com.bingo.mpa.pojo.Package>();
					if(lp != null && lp.size() > 0)
					{
						for(com.bingo.mpa.pojo.Package obj : lp)
						{
							map.put(obj.getPid(), obj);
						}
					}
					model.put("list", list);
					model.put("packages", map);
					return new TemplateRenderer("/manager.html","model",model);
			}
		}
		catch(Exception e)
		{
			log.error("",e);
		}
		return new TemplateRenderer("/manager.html","model",model);
	}
	
	/**
	 * Ajax首页的订单汇总信息
	 * @return
	 */
	@Mapping("/home/stat")
	public Renderer home_stat()
	{
		Stat stat = new Stat();
		try
		{
			String token = HttpUtils.getCookie("mpa_token");
			String sql = "SELECT * FROM P_USER WHERE TOKEN=?";
			if(token == null)
			{
				new TextRenderer(com.alibaba.fastjson.JSON.toJSONString(stat),"utf-8");
			}
			com.bingo.mpa.pojo.User user = QueryHelper.read_cache(com.bingo.mpa.pojo.User.class, "user", token, sql, new Object[]{token});
			if(user == null)
			{
				new TextRenderer(com.alibaba.fastjson.JSON.toJSONString(stat),"utf-8");
			}
			byte role = user.getRole();
			DateMeta meta = com.bingo.mpa.util.Common.getMetaDate("month");
			StringBuffer cs = new StringBuffer("SELECT COUNT(OID) FROM P_ORDER WHERE ORDER_TIME >= ? AND ORDER_TIME < ? ");
			
			switch(role)
			{
				case 1:
				case 2:
					long month = QueryHelper.stat(cs.toString(), new Object[]{new java.sql.Timestamp(meta.getStartTime().getTime()),new java.sql.Timestamp(meta.getEndTime().getTime())});
					
					meta = com.bingo.mpa.util.Common.getMetaDate("today");
					cs.append(" AND CARRIER = ?");
					long unicom = QueryHelper.stat(cs.toString(), new Object[]{new java.sql.Timestamp(meta.getStartTime().getTime()),new java.sql.Timestamp(meta.getEndTime().getTime()),2});
					long mobile = QueryHelper.stat(cs.toString(), new Object[]{new java.sql.Timestamp(meta.getStartTime().getTime()),new java.sql.Timestamp(meta.getEndTime().getTime()),1});
					
					stat.setUnicom(unicom);
					stat.setMobile(mobile);
					stat.setTotal(unicom+mobile);
					stat.setMonth(month);
					break;
				case 3:
					cs.append(" AND S_ACCOUNT=?");
					month = QueryHelper.stat(cs.toString(), new Object[]{new java.sql.Timestamp(meta.getStartTime().getTime()),new java.sql.Timestamp(meta.getEndTime().getTime()),user.getAccount()});
					
					meta = com.bingo.mpa.util.Common.getMetaDate("today");
					cs.append(" AND CARRIER = ?");
					unicom = QueryHelper.stat(cs.toString(), new Object[]{new java.sql.Timestamp(meta.getStartTime().getTime()),new java.sql.Timestamp(meta.getEndTime().getTime()),user.getAccount(),2});
					mobile = QueryHelper.stat(cs.toString(), new Object[]{new java.sql.Timestamp(meta.getStartTime().getTime()),new java.sql.Timestamp(meta.getEndTime().getTime()),user.getAccount(),1});
					
					stat.setUnicom(unicom);
					stat.setMobile(mobile);
					stat.setTotal(unicom+mobile);
					stat.setMonth(month);
					break;
				case 4:
					cs.append(" AND AID=?");
					month = QueryHelper.stat(cs.toString(), new Object[]{new java.sql.Timestamp(meta.getStartTime().getTime()),new java.sql.Timestamp(meta.getEndTime().getTime()),user.getAid()});
					
					meta = com.bingo.mpa.util.Common.getMetaDate("today");
					cs.append(" AND CARRIER = ?");
					unicom = QueryHelper.stat(cs.toString(), new Object[]{new java.sql.Timestamp(meta.getStartTime().getTime()),new java.sql.Timestamp(meta.getEndTime().getTime()),user.getAid(),2});
					mobile = QueryHelper.stat(cs.toString(), new Object[]{new java.sql.Timestamp(meta.getStartTime().getTime()),new java.sql.Timestamp(meta.getEndTime().getTime()),user.getAid(),1});
					
					stat.setUnicom(unicom);
					stat.setMobile(mobile);
					stat.setTotal(unicom+mobile);
					stat.setMonth(month);
					break;
			}
		}
		catch(Exception e)
		{
			log.error("",e);
		}
		return new TextRenderer(com.alibaba.fastjson.JSON.toJSONString(stat),"utf-8");
	}
	
	@Mapping("/logout")
	public Renderer logout()
	{
		HttpUtils.removeCookie("mpa_token","/");
		String tk = HttpUtils.getStringParameter("tk");
		if(tk != null && tk.length() > 0)
		{
			String clientIp = ActionContext.getActionContext().getHttpServletRequest().getRemoteAddr();
			String sql = "SELECT * FROM P_USER WHERE TOKEN=?";
			com.bingo.mpa.pojo.User user = QueryHelper.read_cache(com.bingo.mpa.pojo.User.class, "user", tk, sql, new Object[]{tk});
			if(user != null)
			{
				Log log = new Log(clientIp,(byte)1,(byte)1,"工号为"+user.getAccount()+"的用户退出系统！");
				LogService.getInstance().write(log);
			}
		}
		return new RedirectRenderer("/login");
	}
	
	@Mapping("/pwd")
	public Renderer pwd()
	{
		Map<String,Object> model = new HashMap<String,Object>();
		try
		{
			String token = HttpUtils.getCookie("mpa_token");
			String sql = "SELECT * FROM P_USER WHERE TOKEN=?";
			if(token == null)
			{
				return new RedirectRenderer("/login");
			}
			com.bingo.mpa.pojo.User user = QueryHelper.read_cache(com.bingo.mpa.pojo.User.class, "user", token, sql, new Object[]{token});
			if(user == null)
			{
				return new RedirectRenderer("/login");
			}
			model.put("user", user);
		}
		catch(Exception e)
		{
			log.error("",e);
		}
		return new TemplateRenderer("/modPwd.html","model",model);
	}
	
	@Mapping("/modpwd")
	public Renderer mod_pwd()
	{
		Map<String,Object> model = new HashMap<String,Object>();
		String oldPwd = HttpUtils.getStringParameter("oldPwd");
		String newPwd = HttpUtils.getStringParameter("newPwd");
		String clientIp = ActionContext.getActionContext().getHttpServletRequest().getRemoteAddr();
		try
		{
			String token = HttpUtils.getCookie("mpa_token");
			String sql = "SELECT * FROM P_USER WHERE TOKEN=?";
			if(token == null)
			{
				return new RedirectRenderer("/login");
			}
			com.bingo.mpa.pojo.User user = QueryHelper.read_cache(com.bingo.mpa.pojo.User.class, "user", token, sql, new Object[]{token});
			if(user == null)
			{
				return new RedirectRenderer("/login");
			}
			if(Utils.getMd5Sum(oldPwd).equalsIgnoreCase(user.getPwd()))
			{
				String _update = "UPDATE P_USER SET PWD=? WHERE UID=?";
				QueryHelper.update(_update, new Object[]{Utils.getMd5Sum(newPwd),user.getUid()});
				
				Log log = new Log(clientIp,(byte)1,(byte)1,"工号为"+user.getAccount()+"的用户修改密码，成功！");
				LogService.getInstance().write(log);
				model.put("error", "密码修改成功，<span id=\"sec\" color=\"red\">5</span>秒后返回登录页面。");
				model.put("ret", 1);
			}
			else
			{
				model.put("error", "原密码输入错误，请重新输入！");
			}
		}
		catch(Exception e)
		{
			log.error("",e);
		}
		return new TemplateRenderer("/modPwd.html","model",model);
	}
	
	@Mapping("/common/datetype")
	public Renderer common_datetype()
	{
		DateMeta meta = null;
		String dateType = HttpUtils.getStringParameter("dateType");
		try
		{
			meta = com.bingo.mpa.util.Common.getMetaDate(dateType);
		}
		catch(Exception e)
		{
			log.error("",e);
		}
		return new TextRenderer(com.alibaba.fastjson.JSON.toJSONString(meta),"utf-8");
	}
}
